//
//  MainViewController.swift
//  InterviewContent
//
//  Created by apple on 2016/12/18.
//  Copyright © 2016年 interviewContent. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        addChildViewControllers()
    }

    func addChildViewControllers() {
        addChildViewController(childController: HomeViewController(), title: "Home", imageName: "tabbar_discover")
        addChildViewController(childController: ParseViewController(), title: "Parse", imageName: "tabbar_home")
        addChildViewController(childController: SettingViewController(), title: "Setting", imageName: "tabbar_profile")
    }
    
    /**
     初始化子控制器
     
     :param: childController 需要初始化的子控制器
     :param: title           初始化的标题
     :param: imageName       初始化的图片
     */
    private func addChildViewController(childController: UIViewController, title:String, imageName:String) {
        childController.title = title
        childController.tabBarItem.image = UIImage(named: imageName)
        self.tabBar.tintColor = UIColor.orange
        
        let nav = UINavigationController()
        nav.addChildViewController(childController)
        nav.navigationBar.barTintColor = UIColor.orange
        addChildViewController(nav)
    }

}
